<template>
		<view class="main-box">
			<navBar title="进度审核" @goBack="goBack"></navBar>
			<view style="height: 40rpx;background: #f5f7fa;"></view>
			<view style="padding: 0 20rpx;">
				<u--form labelPosition="top" :model="formData" ref="form1" labelWidth="auto">
					<u-form-item label="审核意见" >
						<view class="form-item form-item-description">
							<u-textarea v-model="formData.content" placeholder="请输入内容" @blur="inputBlur" height="150" confirmType="done"></u-textarea>
							<record class="form-item-icon form-item-icon-voice" @setText="description" ></record>
							<image mode="scaleToFill" class="form-item-icon form-item-icon-clear"
								src="/static/image/login/del1.png" @click="formData.content=''"></image>
						</view>
					</u-form-item>
				</u--form>
			</view>
			<view class="footer-button">
				<view class="button-placeholder"></view>
				<view class="button-group">
					<button @click="fnSure" :loading="isLoading" class="button-primary">确定</button>
				</view>
			</view>
		</view>
</template>

<script>
	import {pmProcessReportApproval} from '@/api/comprehensive/comprehensive.js'
	export default {
		data() {
			return {
				formData: {
					content:''
				},
				id:'',	//上个页面带过来的id
				isLoading:false, //按钮是否被点击
			}
		},
		onLoad(options) {
			this.id = options.id
		},
		methods: {
			inputBlur(e) {
				this.cursor = e.detail.cursor
			},
			description(text) {
				let index = this.cursor || 0
				let str = this.formData.content || ""
				this.cursor += text.length
				text = str.slice(0, index) + text + str.slice(index);
				this.$set(this.formData, "content", text);
				// uni.showModal({
				// 	content:JSON.stringify(this.formData) + text
				// })
			},
			// 返回上一级
			goBack(url) {
				uni.navigateBack()
			},
			fnSure() {
				let _parmas = {
					id: this.id, // 上报id
					reviewStatus:'wtg',	//审核状态
					reviewOpition:this.formData.content,	//审核意见
				}
				if(this.isLoading) return
				this.isLoading = true
				pmProcessReportApproval(_parmas).then(res => {
					if(res.success && res.status === 1) {
						uni.showToast({
							icon:'success',
							title:'审核成功!'
						})
					}
					setTimeout(() => {
						uni.navigateBack({
							url:'/pages/comprehensiveOverhaul/progressReview/progressReview',
							delta: 2
						});
						this.isLoading = false
					},1800)
				})
			}
			
			
		}
	}
</script>

<style lang="scss" scoped>
	.main-box {
		height: 100%;
		width: 100%;
		/* #ifdef MP-WEIXIN */
			padding-top: 200rpx;
		/* #endif */
	}
	.form-item {
		width: 100%;
		position: relative;
	}
	
	.form-item-description {
		.form-item-icon {
			width: 48rpx;
			height: 48rpx;
		}
	
		.form-item-icon-voice {
			position: absolute;
			top: 10rpx;
			right: 16rpx;
			z-index: 3;
		}
	
		.form-item-icon-clear {
			position: absolute;
			right: 16rpx;
			bottom: 10rpx;
			z-index: 2;
		}
	}
	.bottom_btn {
		position: fixed;
		width: 100%;
		bottom: 0;
	}
	/deep/ .u-form-item__body__left__content__label {
		font-size: 32rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #445469;
		margin-bottom: 8rpx;
	}
</style>